/**
 * @fileOverview
 * @author iNahoo
 * @since 2018/5/4.
 */
"use strict";

/**
 * @fileOverview
 * @author iNahoo
 * @since 2018/5/3.
 */
"use strict";

import React, {PureComponent, Component} from 'react';
import ReactDOM from 'react-dom';

class ClickBox extends Component {
    constructor(props) {
        super(props);
        console.log(props);
    }

    render() {
        return <div>???</div>
    }
}

class Main extends PureComponent {
    constructor() {
        super();
        this.span = React.createRef();
    }

    static fakeEvent(originEvent) {
        const e = new CustomEvent('custom', {
            someInfo: '???',
            bubbles: true,
            cancelable: false
        });
        originEvent.target.dispatchEvent(e);
    }

    render() {
        return <div>
            <div onCustom={(e) => {
                console.log(e);
            }}>
                <span onClick={Main.fakeEvent} ref={this.span}>点我</span>
            </div>
            <ClickBox onCustom={Main.fakeEvent}></ClickBox>
        </div>
    }
}

ReactDOM.render(
    <Main></Main>,
    document.getElementById('app'),
);
